package easy;

public class Solution_1979 {

    public int findGCD(int[] nums) {
        int min = 1001, max = 0;
        for (int num : nums) {
            min = Math.min(min, num);
            max = Math.max(max, num);
        }
        while (max % min != 0) {
            int temp = max % min;
            max = min;
            min = temp;
        }
        return min;
    }

    public static void main(String[] args) {
        Solution_1979 model = new Solution_1979();
        System.out.println(model.findGCD(new int[]{2, 5, 6, 9, 10}));
        System.out.println(model.findGCD(new int[]{7, 5, 6, 8, 3}));
        System.out.println(model.findGCD(new int[]{3}));
    }
}
